package com.itheima.day16.第一题;

import java.util.concurrent.Semaphore;

public class MyRunable implements Runnable {
    Semaphore semaphore;
    public MyRunable(Semaphore semaphore) {
        this.semaphore = semaphore;
    }

    @Override
    public void run() {
        try {
            semaphore.acquire();
            System.out.println(Thread.currentThread().getName() + "正在参观浏览室");
            Thread.sleep(3000);
            System.out.println(Thread.currentThread().getName() + "退出浏览室");
            semaphore.release();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
